package cn.kgc.springcloud.controller;

import cn.kgc.springcloud.entity.Order;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: mosin
 * @version: v1.0  2023/1/4
 */
@RestController
@RequestMapping("order")
public class OrderController {

    @Value("${server.port}")
    private String port;
    @RequestMapping("m1")
    public String method1(){
        return "orderService ok port :" +port;
    }


    @RequestMapping("m2")  // 通过用户id 获取订单信息
    public String method2(Integer id){
        System.out.println("id = " + id);
        return "orderService ok id :" +id;
    }

    @RequestMapping("m3/{id}")  // 通过用户id 获取订单信息
    public String method3(@PathVariable("id") Integer id){
        System.out.println("id = " + id);
        return "orderService ok id :" +id;
    }

    @RequestMapping("m4")  // 保存订单信息   参数时json格式
    public String method4(@RequestBody Order order){
        System.out.println("id = " + order);
        return "orderService ok order :" +order;
    }

    @RequestMapping("m5")  // 保存订单信息   参数时json格式
    public Order method5(Integer id){
        Order order = new Order();
        order.setId(id);
        order.setName("手机");
        return order;
    }


}
